//
// Created by gogoqiu on 2021/10/16.
//

#ifndef RAPIDSVN_CMAKE_PREFERENCEADAPTER_H
#define RAPIDSVN_CMAKE_PREFERENCEADAPTER_H
#include "wx/wx.h"
#include "Preference.h"

class MyTagApp;

/*
 *
 */
class PreferenceAdapter {
protected:
    MyTagApp *myTagApp;

    struct Item_range_inserted_package;

    vector<PreferenceView*> items;
    wxWindow* parent;
    wxScrolledWindow* mListBox;

    void OnFrameGetItems( int startPosition, const vector<PreferenceView*>& items );
public:
    class ViewHolder;
    static const int ID_DATA_SET_CHANGED = 5555;
    static const int ID_ITEM_RANGE_INSERTED = 5556;
    //
    PreferenceAdapter( MyTagApp *myTagApp, wxWindow *frame, wxScrolledWindow *listBox );

    void onBindViewHolder ( ViewHolder* holder, int position ) ;
    //
    void onBindViewHolder( ViewHolder *holder,
                           PreferenceView* date );
    //wxFrame
    //ui thread side
    ViewHolder* onCreateViewHolder ( int viewType, PreferenceView * data );

    void clearItemsWithNotify();

    void setItemsWithNotify (  const vector<PreferenceView*>& infos );

    void appendItemsWithNotify (  const vector<PreferenceView*>& infos );

    int getItemViewType ( int position )
    {
        //return super.getItemViewType(position);
        return 0;
    }

    int getItemCount(){
        return items.size();
    }

    void notifyDataSetChanged();
    void notifyItemRangeInserted( int startPosition, int itemCount );

    void OnActionEvent ( wxCommandEvent & event );
};




#endif //RAPIDSVN_CMAKE_PREFERENCEADAPTER_H
